<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f2f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            background-color: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            width: 350px;
        }
        h1 {
            text-align: center;
            color: #1a73e8;
            margin-bottom: 1.5rem;
        }
        .form-group {
            margin-bottom: 1rem;
        }
        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #5f6368;
        }
        input {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #dadce0;
            border-radius: 4px;
            font-size: 1rem;
        }
        input:focus {
            outline: none;
            border-color: #1a73e8;
            box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
        }
        .captcha-group {
            display: flex;
            gap: 10px;
        }
        .captcha-image {
            width: 120px;
            height: 40px;
            cursor: pointer;
            border: 1px solid #dadce0;
            border-radius: 4px;
        }
        button {
            width: 100%;
            padding: 0.75rem;
            background-color: #1a73e8;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        button:hover {
            background-color: #1557b0;
        }
        .error-message {
            color: #d93025;
            text-align: center;
            margin-bottom: 1rem;
            padding: 0.5rem;
            background-color: #fef7f7;
            border-radius: 4px;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h1>用户登录</h1>
        
        {% if error %}
            <div class="error-message">{{ error }}</div>
        {% endif %}
        
        <form method="post">
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" required autofocus>
            </div>
            
            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" id="password" name="password" required>
            </div>
            
            <div class="form-group">
                <label for="captcha">验证码</label>
                <div class="captcha-group">
                    <input type="text" id="captcha" name="captcha" required placeholder="请输入验证码">
                    <img src="{{ url_for('auth.get_captcha') }}" class="captcha-image">
                </div>
            </div>
            
            <button type="submit">登录</button>
        </form>
    </div>

    <script>
        // 点击验证码图片刷新
        document.querySelector('.captcha-image').addEventListener('click', function() {
            this.src = "{{ url_for('auth.get_captcha') }}?" + new Date().getTime();
        });
    </script>
</body>
</html>
    